// .txt

beginzonescript;

variables;

short crime_tolerance = 1;
short last_abil;
short i;
short set_att = 0;

body;

beginstate INIT_STATE;

	add_range_to_group(8,12,1);
	add_range_to_group(13,18,2);

	// 3 groups
	add_range_to_group(19,24,3);
	add_range_to_group(25,28,4);
	add_range_to_group(29,34,5);
	set_level(1005,25);
	set_name(1005,"Sentinel Podling");
	
	add_range_to_group(35,42,6);
	
	set_name(43,"Toroth");
	set_boss_level(43,1);
	set_name(44,"Drayk Technician");
	set_name(45,"Drayk Technician");
	set_name(46,"Drayk Technician");
	set_level(43,30);
	set_level(44,30);
	set_level(45,30);
	set_level(46,30);

	set_name(50,"Ukri");
	
	if (gf(58,10) > 0) {
		set_terrain(54,52,204);
		set_terrain(54,53,205);
		}

	if (gf(100,23) > 0) {
		sf(58,5,1);
		
		erase_char(50);
		}

	if (gf(100,23) == 0) {
		erase_char(60);
		erase_char(61);
		erase_char(62);
		erase_char(63);
		erase_char(64);
		erase_char(65);
		erase_char(66);
		erase_char(67);
		erase_char(68);
		erase_char(69);
		erase_char(70);
		}
		
	if (get_sdf(58,5) > 0) {
		make_zone_hostile();
		}
		
	last_abil = get_current_tick();
	
	set_crime_tolerance(crime_tolerance);
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	// clear zone?
	//if ((zone_clear(ME) == FALSE) && (get_flag(,) > 0)) {
		//print_str_color("",2);
		//clear_zone(ME);	
		//}
	if ((get_crime_level() >= crime_tolerance) && (get_sdf(58,5) == 0)) {
		make_zone_hostile();
		set_flag(58,5,1);
		}
	
	if ((set_att == 0) && ((gf(58,5) > 0) || (gf(100,23) > 0))) {
		set_attitude(1001,10);
		set_attitude(1002,10);
		set_attitude(1003,10);
		set_attitude(1004,10);
		set_attitude(1005,10);
		
		}

	 if (gf(58,5) == 0) {
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(43 + get_ran(1,0,3),"Conduit there?");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(43 + get_ran(1,0,3),"Need new spanner.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(43 + get_ran(1,0,3),"Flawed crystals.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(43 + get_ran(1,0,3),"A good design.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(43 + get_ran(1,0,3),"Could be better.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(50,"I sell to rebels.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(50,"I buy from rebels.");
		if (get_ran(1,0,100) < 10)
			give_char_text_bubble(50,"Curse this leg.");
		}
	
	if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || ((is_group()) && (tick_difference(last_abil,get_current_tick()) > 3))) {
		last_abil = get_current_tick();
		
		if (gf(100,23) > 0) {
			if ((char_ok(51) == FALSE) && (get_ran(1,0,1) == 0))
				spawn_creature(43);
			if ((char_ok(52) == FALSE) && (get_ran(1,0,1) == 0))
				spawn_creature(44);
			if ((char_ok(53) == FALSE) && (get_ran(1,0,1) == 0))
				spawn_creature(45);
			if ((char_ok(54) == FALSE) && (get_ran(1,0,1) == 0))
				spawn_creature(46);
			if (gf(58,18) == 0) {
				if ((char_ok(55) == FALSE) && (get_ran(1,0,1) == 0))
					spawn_creature(47);
				if ((char_ok(56) == FALSE) && (get_ran(1,0,1) == 0))
					spawn_creature(48);
				if ((char_ok(57) == FALSE) && (get_ran(1,0,1) == 0))
					spawn_creature(49);
				if ((char_ok(58) == FALSE) && (get_ran(1,0,1) == 0))
					spawn_creature(50);
				}
			}
			
		}
break;

beginstate 10;
	if ((gf(58,6) == 0) && (gf(58,9) == 0) && (gf(58,5) == 0)) {
		sf(58,9,1);
		set_attitude(1006,10);
		set_attitude(59,10);
		begin_talk_mode(11);
		}
		
break;

beginstate 11;
	if (zone_clear(ME) == FALSE)
		clear_zone(ME);	
	if (gf(100,23) > 0)
		sf(58,18,1);
break;

//	print_str("");
//	set_terrain_string_range(".",3);
//	set_terrain_string_range("The sign says - .",3);
